<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<!-- .breadcrumb -->
	</div>
	<!-- Main content -->
	<div class="page-content">
    	<div class="row">
    	    <div class="page-header">
    			<h1>订单列表</h1>
    		</div>
    		<div class=" col-md-12 col-sm-12 col-xs-12 form">
                <div class="row">
                <form action="<?php echo base_url().'admin/gasstation/order/'.$gasstation_id?>" method="get">
                <input name="su_1" type="hidden" class="" id="su_1" value="0">
                    <div class="wh">
                    	<label>订单编号：</label>
                        <input type="text" id="order_no" name="order_no" value="<?php if (isset($order_no))echo $order_no;?>" />
                    </div>
                    <div class="wh">
                    	<label>交易时间：</label>
                        <input type="text" id="date1" name="date1" value="<?php if (isset($date1))echo $date1;?>" style="width:60%;"/>
                    </div>
                     <div class="wh">
                    	<label>到</label>
                        <input type="text" id="date2" name="date2" value="<?php if (isset($date2))echo $date2;?>" style="width:60%;"/>
                    </div>
                    <div class="wh">
                    	<label>手机号</label>
                        <input type="text" id="phone" name="phone" value="<?php if (isset($phone))echo $phone;?>" style="width:60%;"/>
                    </div>
					<div class="wh">
                    	<label>车贴审核</label>
                        <select name="car_status"  style="height: 23px;">
                    		<option value="">全部</option>
                    		<option value="0" <?php if (isset($car_status)&&$car_status == '0')echo "selected";?>>未审核</option>
                    		<option value="1" <?php if (isset($car_status)&&$car_status == '1')echo "selected";?>>已审核</option>
                    	</select>
                    </div>
                    <div class="wh">
                        <button class="btn btn-sm btn-info" type="submit" onclick='copyText(1)'><i class="icon-search"></i>查询</button>
                        <button class="btn btn-sm btn-info" type="submit" onclick='copyText(2)'><i class="icon-bar-chart"></i>导出</button>
                    </div> 
                </form>
                </div>
            </div>
            <input type="hidden" name="upid" id="upid" value=""/>
            <div class="col-xs-12 margin_t margin_b">
				<div class="table-responsive  tab">
					<table id="sample-table-1" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th class="center" style="width: 3%;">
									<label>
										<input type="checkbox" class="ace" />
										<span class="lbl"></span>
									</label>
								</th>
								
								<th>手机号</th>
								<th>车牌号</th>
								<th>车贴审核</th>
                                <th>订单编号</th>
                                <th>油号</th>
                              
                               
                                <th>支付方式</th>
                                <th>支付状态</th>
                                <th>订单金额</th>
                                <th>折后金额</th>
								<th>服务费</th>
                                <th>实付金额</th>
                               
                                <th>时间</th>
                                <th style="width: 8%;">操作</th>
							</tr>
						</thead> 
						<tbody>
						<?php if (isset($result)&&count($result)>0){
                            	foreach ($result as $app){
                            	?>
							<tr>
								<td class="center">
                                	<p>
									<label>
										<input type="checkbox" class="ace" name="num[]" value="<?php echo $app->id;?>"/>
										<span class="lbl"></span>
									</label>
                                    </p>
								</td>
                                
                                <td><p><?php echo $app->user_phone;?></p></td>
                                <td><p><?php echo $app->car_card;?></p></td>
								<td><p><?php if($app->status>0):?>已审核<?php else:?>未审核<?php endif;?></p></td>
                                <td><p><?php echo $app->order_no;?></p></td>
                                <td><p><?php echo $app->glmodel_name;?></p></td>
                               
                               
                                <td><p><?php
                                	$pay_type = $app->payment;
									if(!empty($app->from_third)){
										$pay_type = "第三方平台支付";
									}elseif($app->payment_id == 2){
                                        $pay_type = "支付宝web支付";
                                    }elseif($app->payment_id == 3){
				                    	$pay_type = "微信公众web号支付";
				                    }elseif($app->payment_id == 6){
				                    	$pay_type = "支付宝APP支付";
									}elseif($app->payment_id == 7){
				                    	$pay_type = "微信APP支付";
									}elseif($app->payment_id == 8){
				                    	$pay_type = "钱包支付";
									}elseif($app->payment_id == 9){
										$pay_type = "小程序支付";
									}
									if($app->qiao_coupon > 0){
										$pay_type .= "(壳牌公众号)";
									}

									echo $pay_type;
									?></p></td>
                                <td><p><?php
									if($app->payment_status == 1&&$app->status==7){
										echo '已退款';
									}elseif($app->payment_status == 0){
										echo "未支付";
									}elseif($app->payment_status == 1){
										echo "已支付";
									}elseif($app->payment_status == 2){
										echo "已取消";
									}
									?></p></td>
                               	<td><?php echo $app->machine_price;?></td>
                               	<td><?php echo $app->zhe_price;?></td>
								<td><p><?php echo round($app->fuwu_price,2);?></p></td>
                                <td><p><?php echo $app->order_price;?></p></td>
                                
                                <td><p><?php echo $app->create_time;?></p></td>
                                <td><p>
                                
                                
                                <?php if ($app->status != 7 ){ ?>
									<a href="javascript:void(0)" onclick="cancelmodal('<?php echo $app->id;?>')" data-toggle="modal" class="btn btn-danger btn-sm">退款</a>
								<?php } ?>
                                <!--
                                	<a class="btn btn-sm btn-info" href="<?php echo base_url().'admin/gasstation/pr int_invoice/' .$app->id;?>">
									<i class="icon-qrcode"></i>打印小票
									</a>-->
                                    </p>
                                </td>
    						</tr>
    						<?php }
                            }else{?>
                            <tr>
                            	<td colspan="14">无数据</td>
                            </tr>
                            <?php }?>
                            </tbody>
                         </table>
                     </div><!-- /.table-responsive -->
				</div>
                <div class="col-sm-12">
                	<div class="modal-footer no-margin-top">
	                	<div class="pull-left record">
							共<?php echo $count;?>条记录
	                    </div>
                		<?php if (isset($page))echo $page;?>
                	</div>
                </div>
            </div><!-- /.row -->
		</div><!-- /.page-content -->
	</div><!-- /.main-content -->
	<div id="cancelModal" class="modal fade" role="dialog" aria-hidden="true">
	<div class="modal-dialog" style="width: 300px">
		<div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h3>提示信息</h3>
			</div>
			<div class="modal-body">
			  <p>订单进行退款后将无法恢复，已支付的金额会直接退回用户支付账户<br>确定要退款吗？</p>
			</div>
			<div class="modal-footer">
			  <input type="hidden" id="cancel_order_id" value="">
			  <a id="cancelbtn" href="#" onclick="cancel()" class="btn btn-danger">确定</a>
			  <a href="#" class="btn btn-info" data-dismiss="modal" aria-hidden="true">取消</a>
			</div>
		</div>
	</div>
</div>
	<script type="text/javascript">
    $(function () {
        $('#date1').datetimepicker({
            format: 'yyyy-mm-dd', 'autoclose': true, minView: 2,language: 'zh-CN'
        });
        $('#date2').datetimepicker({
            format: 'yyyy-mm-dd', 'autoclose': true, minView: 2,language: 'zh-CN'
        });
    });
	</script>
	<script>
		function cancel(){
			$('#cancelModal').modal('hide');
			showLoading('退款中...');
			$.ajax( {
		        url:'<?php echo site_url("admin/order/cancel")?>',
		        data:{order_id:$('#cancel_order_id').val()},
		        type:'post',
		        cache:false,
		        dataType:'json',    
		        success:function(result) {
		        	hideLoading();
		        	if(result.ret == '200'){
		            	if(result.data.code == '0'){
		            		window.location.reload();
		            	}else{
		            		alert("退款失败:"+result.data.msg);
		            	}
		        		
					}else {
						alert("退款失败:"+result.msg);
					}
		        },
		        error : function() {
		        	hideLoading();
					alert("error");
		        }
			});
		}
		function cancelmodal(id){
			$("#cancel_order_id").val(id);
		    $('#cancelModal').modal('show');
		}
		function copyText(type) {
			$("#su_1").get(0).value = type;
		}
	</script>